<?php 
	ini_set("include_path", ".:../:./includes:../includes");

	require_once("includes/constants.php");
	require_once("includes/common.php");
	require_once("includes/template.php");
		
	$view=false;
	$update=false;
	$add=false;
	 if (isset($_REQUEST['operation'])) { //modify employee
	 	if ($_REQUEST['operation'] == "view") {
	 		$view = true;
			head("View Employee Details");
	 	}
		else if ($_REQUEST['operation'] == "update") {
			$update = true;
			head("Update Employee Details");
		}
		else if ($_REQUEST['operation'] == "add") {		
			$add=true;
			head("Add New Employee");
		}
	 }

?>

<table cellspacing="5px"  width="100%">
	<tr>
		<td align="right">
			<label for="e_title">Title</label>	
		</td>
		<td>
			<select id="e_title" name="e_title" >
				<option value="" selected="selected" 
				<?php if ($view || $update) echo "disabled='disabled'" ?>>Select</option>
				<option value="Miss" 
					<?php if ($update || $view) echo "disabled='disabled'" ?>
					<?php if (($update || $view) && !strcmp($_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_title'], "Miss")) echo "selected='selected'"; ?>
				>Miss</option>
				<option value="Mr"
					<?php if ($update || $view) echo "disabled='disabled'" ?>
					<?php if (($update || $view)  && !strcmp($_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_title'], "Mr")) echo "selected='selected'"; ?>
				>Mr</option>
				
				<option value="Mrs"
					<?php if ($update || $view) echo "disabled='disabled'" ?>
					<?php if (($update || $view)  && !strcmp($_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_title'], "Mrs")) echo "selected='selected'"; ?>
				>Mrs</option>
				
				<option value="Ms"
				<?php if ($update || $view) echo "disabled='disabled'" ?>
					<?php if (($update || $view)  && !strcmp($_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_title'], "Miss")) echo "selected='selected'"; ?>
				>Ms</option>
			</select>
		</td>
	</tr>
	<tr>
		<td align="right">
			<label for="e_firstname">First Name</label>			
		</td>
		<td>
			<input  maxlength="20" id="e_firstname" name="e_firstname" type="text" 
			value="<?php if ($update || $view) echo $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_firstname']; ?>"
			<?php if ($update || $view) echo 'readonly'; ?>  />			
		</td>
	</tr>
	<tr>
		<td align="right">
			<label for="e_surname">Surname</label>			
		</td>
		<td>
			<input id="e_surname" name="e_surname" maxlength="40" type="text" 
			value="<?php if ($update || $view) echo $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_surname']; ?>" 
			<?php if ($update || $view) echo 'readonly'; ?> />			
		</td>
	</tr>
	<tr>
		<td align="right">
			<label for="e_email">Email</label>		
		</td>
		<td>
			<input id="e_email" name="e_email" maxlength="30" type="text" 
			value="<?php if ($update || $view) echo $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_email']; ?>"
			<?php if ( $view) echo 'readonly'; ?> />						
		</td>
	</tr>
	<tr>
		<td align="right">
			<label for="e_repeat_email">Repeat Email</label>	
		</td>
		<td>
			<input id="e_repeat_email" maxlength="30" type="text" 
			value="<?php if ($update || $view) echo $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_email']; ?>"
			<?php if ($view) echo 'readonly'; ?> />									
		</td>
	</tr>
	<tr>
		<td align="right">
			<label for="e_phone_no">Phone</label>	
		</td>
		<td>
			<input maxlength="11" id="e_phone_no" name="e_phone_no" maxlength="30" type="text" 
			value="<?php if ($update || $view) echo $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_phone_no']; ?>"
			<?php if ( $view) echo 'readonly'; ?> />									
		</td>
	</tr>
	<tr>
		<td align="right">
			<label for="e_hours_per_day">Hours/Day</label>	
		</td>
		<td> 
			<select id="e_hours_per_day" name="e_hours_per_day" <?php if ( $view) echo 'readonly'; ?> >
				<option value="" selected="selected" <?php if ($view) echo "disabled='disabled'" ?> >Select</option>
				<option value="4" 
					<?php if (($update || $view) && $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_hours_per_day'] == 4) echo "selected='selected'" ?>   
					<?php if ($view) echo "disabled='disabled'" ?>
				> 4 hours
				</option>
				<option value="5" 
					<?php if (($update || $view)  && $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_hours_per_day'] == 5) echo "selected='selected'" ?>   
					<?php if ($view) echo "disabled='disabled'" ?>   
				>5 hours
				</option>
				<option value="6" 
					<?php if (($update || $view)  && $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_hours_per_day'] == 6) echo "selected='selected'" ?>   
					<?php if ($view) echo "disabled='disabled'" ?>
				>6 hours
				</option>
				<option value="7" 
					<?php if (($update || $view)  && $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_hours_per_day'] == 7) echo "selected='selected'" ?>  
					<?php if ($view) echo "disabled='disabled'" ?>
				>7 hours
				</option>
				<option value="8" 
					<?php if (($update || $view)  && $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_hours_per_day'] == 8) echo "selected='selected'" ?>   
					<?php if ($view) echo "disabled='disabled'" ?>
				>8 hours
				</option>				
			</select>
		</td>
	</tr>		
				
</table>


	 	
<?php 
	if ($add) foot("ADD", "addEmployeeLogic.php"); 
	else if ($update) foot("UPDATE", "updateEmployeeLogic.php?selectedEmployee=" .
	 $_SESSION[EMPLOYEES][$_REQUEST['selectedEmployee']]['e_employee_id']); 
	else foot();
?>


